function [PQ] = SS_AddEqualTasks(PQ, sensor1TargetOrder, sensor2TargetOrder, maxPriority)
%SS_AddEqualTasks works out which targets are seen by both sensors.
% Work out the "equals" relations and add new relations to the top
% priority bin in the Queue.
s1rows = size(sensor1TargetOrder, 1);
s1cols = size(sensor1TargetOrder, 2);
s2rows = size(sensor2TargetOrder, 1);
s2cols = size(sensor2TargetOrder, 2);

for a = 1:s1rows
  for b = 1:s1cols
    if sensor1TargetOrder(a, b) > 0
      for c = 1:s2rows
        for d = 1:s2cols
          if sensor2TargetOrder(c, d) > 0
            if (sensor1TargetOrder(a, b) == sensor2TargetOrder(c,d))
              found = 0;
              for taskNr = 1:PQ_Size(PQ)
                Task = PQ_Fetch_Task(PQ, taskNr, 0);
                if Task.id == sensor1TargetOrder(a, b)
                  found = 1;
                  break;
                end
              end
              if ~found
                % add new task to the priority queue in bin 1
                Task = struct('type', 'track', 'id', sensor1TargetOrder(a, b));
                PQ = PQ_Add_Task(PQ, Task, maxPriority);
              end
            end
          end
        end
      end
    end
  end
end